package com.zh.authority.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import javacommon.base.*;
/**
 * @author grey2 email:grey2@126.com
 * @version 1.0
 * @since 1.0
 */
@Entity
@Table(name = "t_menu")
public class Menu extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "Menu";
	public static final String ALIAS_ID = "菜单ID";
	public static final String ALIAS_MENU_NAME = "菜单名称";
	public static final String ALIAS_MENU_VIEW_URL = "页面路径";
	public static final String ALIAS_URL = "资源权限URL";
	public static final String ALIAS_MENU_LEVEL = "级别";
	public static final String ALIAS_PARENT_ID = "父菜单ID";
	public static final String ALIAS_IS_SHOW = "是否显示为菜单";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * 菜单ID       db_column: id 
     */ 	
	
	private java.lang.Integer id;
    /**
     * 菜单名称       db_column: menuName 
     */ 	
	@Length(max=255)
	private java.lang.String menuName;
    /**
     * 页面路径       db_column: menuViewUrl 
     */ 	
	@Length(max=255)
	private java.lang.String menuViewUrl;
    /**
     * 资源权限URL       db_column: url 
     */ 	
	@Length(max=255)
	private java.lang.String url;
    /**
     * 级别       db_column: menuLevel 
     */ 	
	
	private java.lang.Integer menuLevel;
    /**
     * 父菜单ID       db_column: parentId 
     */ 	
	
	private java.lang.Integer parentId;
    /**
     * 是否显示为菜单       db_column: isShow 
     */ 	
	
	private java.lang.Integer isShow;
	//columns END


	public Menu(){
	}

	public Menu(
		java.lang.Integer id
	){
		this.id = id;
	}

	

	public void setId(java.lang.Integer value) {
		this.id = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "id", unique = true, nullable = false, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getId() {
		return this.id;
	}
	
	@Column(name = "menuName", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getMenuName() {
		return this.menuName;
	}
	
	public void setMenuName(java.lang.String value) {
		this.menuName = value;
	}
	
	@Column(name = "menuViewUrl", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getMenuViewUrl() {
		return this.menuViewUrl;
	}
	
	public void setMenuViewUrl(java.lang.String value) {
		this.menuViewUrl = value;
	}
	
	@Column(name = "url", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getUrl() {
		return this.url;
	}
	
	public void setUrl(java.lang.String value) {
		this.url = value;
	}
	
	@Column(name = "menuLevel", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getMenuLevel() {
		return this.menuLevel;
	}
	
	public void setMenuLevel(java.lang.Integer value) {
		this.menuLevel = value;
	}
	
	@Column(name = "parentId", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getParentId() {
		return this.parentId;
	}
	
	public void setParentId(java.lang.Integer value) {
		this.parentId = value;
	}
	
	@Column(name = "isShow", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getIsShow() {
		return this.isShow;
	}
	
	public void setIsShow(java.lang.Integer value) {
		this.isShow = value;
	}
	
	/****
	private Set menuRoleMappings = new HashSet(0);
	public void setMenuRoleMappings(Set<MenuRoleMapping> menuRoleMapping){
		this.menuRoleMappings = menuRoleMapping;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "menu")
	public Set<MenuRoleMapping> getMenuRoleMappings() {
		return menuRoleMappings;
	}
	 */
	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Id",getId())
			.append("MenuName",getMenuName())
			.append("MenuViewUrl",getMenuViewUrl())
			.append("Url",getUrl())
			.append("MenuLevel",getMenuLevel())
			.append("ParentId",getParentId())
			.append("IsShow",getIsShow())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Menu == false) return false;
		if(this == obj) return true;
		Menu other = (Menu)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
}

